Answer:

Yes.

Running a Method

Here is the example program, now with additional statements:

class StringDemo2
{
  public static void main ( String[] args )
  {
    String str;
    int    len;

    str = new String( "Elementary, my dear Watson!" );

    len = str.length();

    System.out.println("The length is: " + len );

  }
}

The phrase

str.length();

runs the length() method of the object referred to by str. This method counts the number of characters in the data of the object. In our object, it counts the number of characters in "Elementary, my dear Watson!" which is 27. That value is then assigned to the int variable len.

Calling a method is asking for a method to be run. The above phrase called the length() method.

QUESTION 8:

Do space characters and punctuation characters count in the length of a string?